package com.my.selectcoursesystem.service.serviceImpl;

import com.my.selectcoursesystem.bean.Student;
import com.my.selectcoursesystem.dao.StudentDao;
import com.my.selectcoursesystem.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("StudentService")
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;

    public StudentServiceImpl(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    public StudentServiceImpl() {
    }

    @Override
    public Student getStudent(String s_code, String s_password) {
        return this.studentDao.findByScodeAndSpassword(s_code, s_password);
    }

    @Override
    public Student getStudentBySid(String sid) {
        return this.studentDao.findBySid(sid);
    }

    @Override
    public Boolean modifyStu(Student student) {
        try {
            this.studentDao.save(student);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}
